home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / Manuels & Misc / Assembly / AOA.ZIP / CH13 / ARGTEST.ASM next >
Encoding:
Assembly Source File  |  1993-08-23  |  1.1 KB  |  60 lines

  1.  
  2.         include     stdlib.a
  3.         includelib    stdlib.lib
  4.  
  5.  
  6. dseg        segment    para public 'data'
  7. ArgCnt        word    0
  8. dseg        ends
  9.  
  10.  
  11. cseg        segment    para public 'code'
  12.         assume    cs:cseg, ds:dseg
  13.  
  14.  
  15. Main        proc
  16.         mov    ax, dseg
  17.         mov    ds, ax
  18.         mov    es, ax
  19.  
  20. ; Must call the memory manager initialization routine if you use any
  21. ; routine which calls malloc!  ARGV is a good example of a routine which
  22. ; calls malloc.
  23.  
  24.         meminit
  25.  
  26.  
  27.         argc            ;Get the command line arg count.
  28.         jcxz    Quit        ;Quit if no cmd ln args.
  29.         mov    ArgCnt, 1    ;Init Cmd Ln count.
  30. PrintCmds:    printf            ;Print the
  31.         byte    "\n%2d: ",0
  32.         dword    ArgCnt
  33.  
  34.         mov    ax, ArgCnt    ;Get the next command line guy.
  35.         argv
  36.         puts
  37.         inc    ArgCnt        ;Move on to next arg.
  38.         loop    PrintCmds       ;Repeat for each arg.
  39.         putcr
  40.  
  41.  
  42. Quit:        ExitPgm            ;DOS macro to quit program.
  43. Main        endp
  44.  
  45. cseg            ends
  46.  
  47.  
  48.  
  49. sseg        segment    para stack 'stack'
  50. stk        db    1024 dup ("stack   ")
  51. sseg        ends
  52.  
  53.  
  54. ;zzzzzzseg is required by the standard library routines.
  55.  
  56. zzzzzzseg    segment    para public 'zzzzzz'
  57. LastBytes    db    16 dup (?)
  58. zzzzzzseg    ends
  59.         end    Main
  60.